package com.zhuannimei.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.zhuannimei.R;
import com.zhuannimei.domain.ZnmMessage;
import com.zhuannimei.utility.JackViewHolder;
import com.zhuannimei.utility.MessageUtil;

/**
 * 商品列表适配器
 * 
 * @author Jack 2013-12-4
 * 
 * 
 */
public class MessageAdapter extends BaseObjectListAdapter {

	private static final String TAG = "MessageAdapter";

	public MessageAdapter(Context context, List<? extends Object> datas) {
		super(context, datas);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.message_item, null);
		} 
		ImageView photo = JackViewHolder.get(convertView, R.id.uschool_news_user_img_IV);
		TextView name = JackViewHolder.get(convertView, R.id.uschool_news_username_TV);
		TextView content = JackViewHolder.get(convertView, R.id.uschool_news_content_TV);
		TextView time = JackViewHolder.get(convertView,R.id.uschool_news_time_TV);
		final ZnmMessage omsg = (ZnmMessage) mDatas.get(position);
		switch (MessageUtil.getMsgType(omsg)) {
		case OFFICAL_N:
			// 官方通知
			break;
		case DETAIL_N:
			// 订单审核通过通知
			name.setText("积分兑换通知");
			content.setText(omsg.getContent());
			time.setText(omsg.getTime());
			photo.setBackgroundResource(R.drawable.f12);
			break;
		case POINT_N:
			// 每日收益通知
			
			break;
		case LUCKY_N:
			// 抽奖结果通知
			name.setText("一元购通知");
			content.setText("抽奖结果:"+omsg.getContent());
			time.setText(omsg.getTime());
			photo.setBackgroundResource(R.drawable.f7);
			break;
		case RANKING_N:
			// 积分榜通知
			name.setText("积分榜通知");
			content.setText(omsg.getContent());
			time.setText(omsg.getTime());
			photo.setBackgroundResource(R.drawable.f11);
			break;
		case PROMOTE_N:
			// 推广通知
			break;

		default:
			break;
		}
		return convertView;
	}

}
